﻿using DevExpress.Data.Utils;
using HalconDotNet;
using ImageDefine;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ImageTool2DCal
{
    public partial class FormSetting : DevExpress.XtraEditors.XtraForm
    {
        ImageTask imageTask;
        ImageTool2DCal imageTool;
        ImageActioner2DCal imageActioner;
        public FormSetting()
        {
            InitializeComponent();
        }
        public FormSetting(ImageTask imageTaskIn, ImageTool2DCal imageToolIn, ImageActioner2DCal imageActionerIn)
        {
            InitializeComponent();
            imageTask = imageTaskIn;
            imageTool = imageToolIn;
            imageActioner = imageActionerIn;
        }

        private void FormSetting_Load(object sender, EventArgs e)
        {
            propertyGridControl1.SelectedObject = imageTool.Setting;
            imageTask.LoadRegeditFile(smartDisplayControl1);

            comboBoxEditFormName.Text = imageTool.strFormName;
            comboBoxEditToName.Text = imageTool.strToName;
            foreach (ImageToolBase itemTool in imageTask.listTools)
            {
                if (itemTool is IPoint || itemTool is ILineTool || itemTool is ICircleTool)
                {
                    comboBoxEditFormName.Properties.Items.Add(itemTool.Name);
                    comboBoxEditToName.Properties.Items.Add(itemTool.Name);
                }
               
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            imageTool.imageTask.LoadRegeditFile(smartDisplayControl1);

            imageTool.imageTask.RunFileImage( smartDisplayControl1, smartDisplayControl1.ho_Image);

            imageTool.Run(smartDisplayControl1.ho_Image, smartDisplayControl1);
        }

        private void simpleButtonLoadImage_Click(object sender, EventArgs e)
        {
            imageTool.imageTask.LoadRegeditFile(smartDisplayControl1);
        }

        private void comboBoxEditFormName_SelectedValueChanged(object sender, EventArgs e)
        {
            imageTool.strFormName = comboBoxEditFormName.EditValue.ToString();
        }

        private void comboBoxEditToName_SelectedValueChanged(object sender, EventArgs e)
        {
            imageTool.strToName = comboBoxEditToName.EditValue.ToString();
        }
    }
}
